#@author Jorge Niedbalski R. <jnr@niedbalski.org>

import httplib
import urllib
import simplejson as json
import sys

def	clientTest():
	
	task = { 'queue_name' : 'mail_queue' , 'arguments' : [ '/tmp'  ], 'notifications' : [ { 'url' : 'http://www.notification.org' } ] }
	encoded_task = json.JSONEncoder().encode(task)	

	params  = urllib.urlencode({'task' : encoded_task })
	headers = { 
				"Content-type" : "application/x-www-form-urlencoded", 
				"Accept" : "text/plain" 
			  }

	conn     = httplib.HTTPConnection("localhost:8090")
	conn.request("POST", "/squeue/add", params, headers )
	
	response = conn.getresponse()
	conn.close()	

if __name__ == "__main__":
	clientTest()
